import socket
from Config import conf

class DeviceHolder:
    def __init__(self,ip):
        self.socketUDP = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
        self.socketUDP.bind((ip,9999))

    def hold(self):
        while True:
            data,addr = self.socketUDP.recvfrom(1024)
            # print(data)
            if data == b'broadcast':
                self.socketUDP.sendto(('here:%s:%d'%(conf.username,conf.myavatar)).encode("utf-8"),addr)
